/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

/**
 *
 * @author danang
 */
public class Timer {
    
    long start;
    
    public Timer() {
        start = System.currentTimeMillis();
    }
    
    public String printExecution_timeOnly() {
        StringBuilder sb = new StringBuilder();
        long exec = System.currentTimeMillis() - start;
        sb.append(exec).append(" ms.");
        return sb.toString();
    }
    
    // print execution time
    public String printExecution_time(String process) {
        long exec = System.currentTimeMillis() - start;
        int minute = (int) ((exec / 1000) / 60);
        int seconds = (int) ((exec / 1000) % 60);
        int miliseconds = (int) (exec % 1000);
        StringBuilder sb = new StringBuilder();
        sb.append(process).append(FileListing.newLine);
        sb.append("Execution time ").append(minute).append(" minutes ").append(seconds).append(" seconds ").append(miliseconds).append(" ms.");
        System.out.println(sb.toString());
        return sb.toString();
    }
}
